﻿@model Orchard.Users.ViewModels.UsersIndexViewModel
@using Orchard.Users.Models;
@using Orchard.Users.ViewModels;
@{
    var userIndex = 0;

    Layout.Title = T("Users").ToString();
}
@using (Html.BeginFormAntiForgeryPost())
{ 
    @Html.ValidationSummary()
   
    <fieldset class="bulk-actions">
        @Html.TextBoxFor(m => m.Options.Search, new { @class = "text" })
        <label for="filterResults">@T("Filter:")</label>
        <select id="filterResults" name="@Html.NameOf(m => m.Options.Filter)">
            @Html.SelectOption(Model.Options.Filter, UsersFilter.All, T("All Users").ToString())
            @Html.SelectOption(Model.Options.Filter, UsersFilter.Approved, T("Approved Users").ToString())
            @Html.SelectOption(Model.Options.Filter, UsersFilter.Pending, T("Pending Users").ToString())
            @Html.SelectOption(Model.Options.Filter, UsersFilter.EmailPending, T("Pending Emails").ToString())
        </select>
        <label for="filterResults">@T("Sort by:")</label>
        <select id="filterResults" name="@Html.NameOf(m => m.Options.Order)">
            @Html.SelectOption(Model.Options.Order, UsersOrder.Name, T("Name").ToString())
            @Html.SelectOption(Model.Options.Order, UsersOrder.Email, T("Email").ToString())
        </select>
        <button type="submit" name="submit.Filter" value="@T("Filter")">@T("Filter")</button>
    </fieldset>
    <fieldset>
        <table class="items">
            <thead>
                <tr>
                   
                    <th scope="col">&nbsp;&darr;
                        @T("Name")
                    </th>
                    <th scope="col">@T("Email")
                    </th>
                    <th scope="col">@T("Actions")
                    </th>
                </tr>
            </thead>
            @foreach (var entry in Model.Users)
            { 
                <tr>

                    <td>
                        @if (entry.User.RegistrationStatus == UserStatus.Approved && entry.User.EmailStatus == UserStatus.Approved)
                        { 
                            <img class="icon" src="@Href("~/Modules/Orchard.Users/Content/Admin/images/online.gif") " alt="@T("Approved") " title="@T("User is approved") " /> 
                        }
                        else
                        { 
                            <img class="icon" src="@Href("~/Modules/Orchard.Users/Content/Admin/images/offline.gif") " alt="@T("Moderated") " title="@if (entry.User.EmailStatus == UserStatus.Approved)
                                                                                                                { @T("E-mail validation is pending") }" />
                        }
                        @Html.ActionLink(entry.User.UserName, "EditUserPassword", new { entry.User.Id })
                    </td>
                    <td>
                        @entry.User.Email
                    </td>
                    <td>
                        @Html.ActionLink(T("Change password").ToString(), "EditUserPassword", new { entry.User.Id })
                    </td>
                </tr>
                        userIndex++;
            }
        </table>
        @Display(Model.Pager)
    </fieldset>
}
